package com.yeheng.test.homework2;

/**
 * @PackgeName: com.yeheng.test
 * @ClassName: Singleton2
 * @Author: YH
 * Date: 2021/1/1 23:33
 * project name: homework1
 * @Version:
 * @Description:
 */
//懒汉式
public class Singleton2 {

    private static volatile Singleton2 single2;

    private Singleton2(){

    }

    public static Singleton2 getSingle2(){
        if (single2==null){
            synchronized (Singleton2.class){
                if (single2==null){
                    single2 = new Singleton2();
                }
            }
        }
        return single2;
    }
}
